//
//  SSMainTabBarController.m
//  电商项目
//
//  Created by Esther on 2017/2/18.
//  Copyright © 2017年 Esther. All rights reserved.
//

#import "SSMainTabBarController.h"
#import "SSMainNavigationController.h"
#import "UIImage+Additions.h"


@interface SSMainTabBarController ()

@end

@implementation SSMainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    
}


#pragma mark -
#pragma mark - 搭建界面
- (void)setupUI{
    // 透明度
    self.tabBar.alpha = 1.0;
    self.tabBar.translucent = NO;
    
    // 添加子控制器
    NSMutableArray *arrM = [NSMutableArray array];
    [arrM addObject:[self addChildCotrollerClassName:@"SSHomeController" title:@"限时购" imageName:@"Home"]];
    [arrM addObject:[self addChildCotrollerClassName:@"SSClassifyController" title:@"分类" imageName:@"Classify"]];
    [arrM addObject:[self addChildCotrollerClassName:@"SSShoppingCarController" title:@"购物车" imageName:@"ShoppingCar"]];
    [arrM addObject:[self addChildCotrollerClassName:@"SSMineController" title:@"我的" imageName:@"Mine"]];
    
    self.viewControllers = arrM.copy;
    
    
}

- (UINavigationController *)addChildCotrollerClassName:(NSString *)className title:(NSString *)title imageName:(NSString *)imageName{
    Class cls = NSClassFromString(className);
    
    UIViewController *viewController = [[cls alloc] init];
    
    viewController.tabBarItem.image = [UIImage ss_imageWithImageName:imageName];
    viewController.tabBarItem.selectedImage = [UIImage ss_imageWithImageName:[NSString stringWithFormat:@"%@_hei",imageName]];
    viewController.title = title;
//    viewController.view.backgroundColor = [UIColor ss_randomColor]
    //75	182	238
    NSDictionary *dictSelected = @{NSForegroundColorAttributeName : [UIColor ss_colorWithRed:75 green:182 blue:238]};
    NSDictionary *dictNormal = @{NSForegroundColorAttributeName : [UIColor ss_colorWithRed:150 green:150 blue:150]};
    [viewController.tabBarItem setTitleTextAttributes:dictNormal forState:UIControlStateNormal];
    [viewController.tabBarItem setTitleTextAttributes:dictSelected forState:UIControlStateSelected];
    
    
    UINavigationController *navC = [[SSMainNavigationController alloc] initWithRootViewController:viewController];
    
    return navC;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
